package traceMyItems.server;
import java.util.logging.Logger;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;






import traceMyItems.business.TraceMyItems;
import traceMyItems.business.User;

public class Logout extends HttpServlet{ 
  /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final Logger log = Logger.getLogger(Logout.class.getName());
	
public void doGet(HttpServletRequest request, 
  HttpServletResponse response)
  throws ServletException,IOException{
  
	
	
  }

public void doPost(HttpServletRequest request, 
		  HttpServletResponse response)
		  throws ServletException,IOException
		  {
			String strJsonResponse = "";
			response.setContentType("text/x-json;charset=UTF-8");           
		    response.setHeader("Cache-Control", "no-cache");
		    
			log.info("Pedido de LOGOUT recibido");
					
		    	
			TraceMyItems objManager = TraceMyItems.getInstance();			
			
			try
			{
				
				objManager.logout();
				response.getWriter().write("{\"status\":\"ok\"}");	
			
			       
			     
			     
			}
			catch(Exception ex)
			{				
				log.warning("Excepcion cerrando sesion de usuario: "+ex.getMessage());
				strJsonResponse = "{\"status\":\"not_ok\", \"mensaje\":\"Surgio un error\" }";
			
				
				response.getWriter().write(strJsonResponse);
		   
			}
			
		  }

}